package com.woniuxy.joylifeshop.service.serviceImpl;

import com.woniuxy.common.entity.ShopCommodityImage;
import com.woniuxy.common.mapper.ShopCommodityImageMapper;
import com.woniuxy.joylifeshop.exception.CommodityImageException;
import com.woniuxy.joylifeshop.service.CommodityImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class CommodityImageServiceImpl implements CommodityImageService {

    @Autowired
    ShopCommodityImageMapper shopCommodityImageMapper;


    @Override
    public ShopCommodityImage jointImageObject() {

        try {
            ShopCommodityImage shopCommodityImage = new ShopCommodityImage();
            shopCommodityImage.setImgId(UUID.randomUUID().toString());

            shopCommodityImageMapper.insert(shopCommodityImage);

            return shopCommodityImage;
        } catch (Exception e) {
            e.printStackTrace();
            throw new CommodityImageException();
        }
    }
}
